package com.eastseeway.radioproject.database;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.eastseeway.radioproject.entities.BeanVBus;

import java.util.List;
/*
* 保存不同频率 不同能量下的校正值*/
@Dao
public interface VBusDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertVBus(BeanVBus beanVBus);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertVBusList(List<BeanVBus> beanVBusList);

    @Query("select * from beanvbus where freq = :freq")
    LiveData<List<BeanVBus>> queryVBusByFreq(String freq);

    @Query("select * from beanvbus order by id")
    LiveData<List<BeanVBus>> queryAllVBus();

    @Query("select * from beanvbus where handle_type = :handleType and freq = :freq order by power")
    LiveData<List<BeanVBus>> queryVBusByHandleTypeAndFreq(String handleType,String freq);

    @Query("select voltage from beanvbus where id = :id")
    String queryVoltageById(String id);

    @Query("delete from beanvbus")
    void deleteAll();

//    根据handle_type来进行删除
    @Query("delete from beanvbus where handle_type = :handleType")
    void deleteByHandleType(String handleType);
}
